package springapp.web;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import springapp.service.IDesignationService;
import springapp.service.IIndustryService;
import springapp.service.ILocationService;
import springapp.util.Utils;

@Controller
public class CacheController {

	@Autowired(required = true)
	private IIndustryService industryService;

	@Autowired(required = true)
	private ILocationService locationService;

	@Autowired(required = true)
	private IDesignationService designationService;

	@RequestMapping(value = "/getCache.htm", method = RequestMethod.GET)
	public @ResponseBody
	String handleRequest() {
		Set<String> allIndustries = industryService.getAllIndustries();
		Set<String> allLocations = locationService.getAllLocations();
		Set<String> allDesignations = designationService.getAllDesignations();

		Map<String, Set<String>> map = new HashMap<String, Set<String>>();
		map.put("location", allLocations);
		map.put("industry", allIndustries);
		map.put("designation", allDesignations);

		return Utils.getJson(map);
	}
}
